package usernew;

import java.util.Scanner;
import javax.xml.transform.Source;
import user.Userdaoio;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/5/11 8:59
 * @description:
 */
public class Usermain {

 //public static Userdao dao = new Userdaomap();

  public static Userdao dao = new Userdaoio();


  public static Scanner sc=new Scanner(System.in);
  public static Scanner sa=new Scanner(System.in);
  public static void main(String[] args) {
    while (true)
      welcome();




  }

  private static void welcome() {
    System.out.println("------欢迎光临------");
    System.out.println("1.注册");
    System.out.println("2.登陆");
    System.out.println("3.查询所有记录");
    System.out.println("4.退出");

    System.out.println("5.你想干什么扣什么数字");


    int num=sc.nextInt();
    switch (num)
    {
      default:
        System.out.println("你输入错了，蠢货");
break;
      case 1:
        zhuce();
        break;
      case 2:
        login();
        break;
      case 3:
        chaall();
        break;
      case 4:
        System.out.println("别来了不欢迎你");
        System.exit(0);
break;


    }

  }


  //注册界面

  private static void zhuce() {
    System.out.println("------=-注册界面-------");
    System.out.println("输入用户的姓名");
    String name=sa.nextLine();

    System.out.println("输入用户的学号");
    int id=sc.nextInt();

    System.out.println("输入用户的年龄");
    int age=sc.nextInt();

    System.out.println("输入用户的密码");
    String passwpord=sa.nextLine();



    User user=new User(name,id,age,passwpord);
 dao.zhuce(user);

    System.out.println("注册成功");



  }


  //查询所有
  private static void chaall() {
    System.out.println("------=-查询用户界面-------");
dao.chaall();


  }


  //登陆界面
  private static void login() {


    System.out.println("------=-登陆界面-------");



    System.out.println("输入用户的用户名");
    String name=sa.nextLine();

    System.out.println("输入用户的密码");
   String passwpord=sa.nextLine();

    boolean flag=dao.login(name,passwpord);
    if(flag)
    {
      System.out.println("登陆成功,你可以玩游戏了");
    }
   else
    {
      System.out.println("登陆失败，继续操作会封号");
    }

  }

}
